import { createSlice } from '@reduxjs/toolkit'

const initialState = {
  token: '',
  userInfo: '',
  assemblySize: 'middle',
  language: '',
  themeConfig: {
    primary: '#1890ff',
    isDark: false,
    weakOrGray: '',
  },
}
const globalSlice = createSlice({
  name: 'global',
  initialState,
  reducers: {
    // 设置token的reducer
    setToken: (state, { payload }) => {
      state.token = payload // 更新state中的token变量为action.payload的值
    },
    setLanguage: (state, { payload }) => {
      state.language = payload // 更新state中的token变量为action.payload的值
    },
  },
})

export const { setToken, setLanguage } = globalSlice.actions // 导出setToken action creator
export default globalSlice.reducer // 导出reducer
